<?php
/**
 * Created by PhpStorm.
 * User: Qch
 * Date: 2016/9/10
 * Time: 12:01
 */

namespace J\Util;

use J\IAsync;


/**
 * 异步器，实现了自动加载和保存
 *
 */
class FileAsynchronizer implements IAsync
{
    protected $file;

    /**
     * FileAsynchronizer constructor.
     * @param $file
     */
    public function __construct($file)
    {
        $this->file = $file;
    }

    public function load()
    {
        return File::get($this->file, true);
    }

    public function save($values)
    {
        File::add($this->file, $values);
    }
}